import request from '@/utils/request'

const baseUrl = process.env.VUE_APP_BASE_API

export function login(data) {
  return request({
    url: `${baseUrl}/login`,
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: `${baseUrl}/user/getInfo`,
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}

export function listUser() {
  return request({
    url: `${baseUrl}/user`,
    method: 'get'
  })
}

export function updateUser(data) {
  return request({
    url: `${baseUrl}/user`,
    method: 'post',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: `${baseUrl}/user`,
    method: 'delete',
    params: data
  })
}

export function restPasswordUser(id) {
  return request({
    url: `${baseUrl}/user/resetUserPassword`,
    method: 'put',
    data: { id: id }
  })
}
